test: resolve PR #242 review comments (CodeQL + Copilot)#243
Merged
Conversation
Address CodeQL (github-code-quality) and Copilot review comments on PR #242: CodeQL: unused imports / variables - test_queue_service_internals.py: drop redundant `tp = _task_param()` in test_output_cleanup_refuses_broad_prefix; drop unused `_no_op_worker` in test_start_service_runs_and_completes. - test_application_base_init.py: drop unused `import inspect` and unused `app` local in test_init_loads_app_config_when_url_set. - test_agent_speaking_capture.py: drop unused `datetime`/`MagicMock` imports. - test_agent_telemetry.py: drop unused `from datetime import UTC, datetime` (only the literal string ` UTC` is used, not the imports). - test_agent_telemetry_records.py: drop unused `import pytest`. - test_config.py (backend SAS blob): drop unused `pytest` import and unused `default_config` symbol from the import list (still referenced via `blob_config_module.default_config`). Copilot review: order-dependent MagicMock leak - test_async_helper_extra.py and test_helper_extra.py: replace `type(MagicMock()).__name__ = ...` mutation in `_wire_credential` with a dedicated dynamically-created stub class per credential type. Mutating `__name__` on the shared MagicMock class globally renamed that class for any later test that introspected `type(...)`, making the suite order-dependent/flaky. The new stubs scope each credential class name to its own type while preserving `hasattr(cred, 'account_key')` semantics for both account-key and AAD code paths. Verification - Backend unit tests: 585 passing (1 unrelated environmental failure against example.azconfig.io), 93.28% coverage. - Processor unit tests: 812 passing, 87.44% coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Test-only cleanup PR addressing review feedback on PR #242: removes unused imports/variables flagged by CodeQL and fixes a MagicMock class mutation that caused order-dependent test behavior in blob storage tests.
Changes:
- Drop unused imports (
pytest,inspect,datetime,MagicMock) and unused locals across several processor and backend test files. - Replace
type(MagicMock()).__name__ = ...mutation with dedicated dynamically-created stub classes per credential type in_wire_credentialhelpers, preventing cross-test leakage.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/processor/src/tests/unit/utils/test_agent_telemetry.py | Remove unused UTC, datetime import. |
| src/processor/src/tests/unit/utils/test_agent_telemetry_records.py | Remove unused pytest import. |
| src/processor/src/tests/unit/services/test_queue_service_internals.py | Remove redundant tp = _task_param() and unused inner _no_op_worker. |
| src/processor/src/tests/unit/libs/base/test_application_base_init.py | Remove unused inspect import and unused app local. |
| src/processor/src/tests/unit/libs/agent_framework/test_agent_speaking_capture.py | Remove unused datetime and MagicMock imports. |
| src/backend-api/src/tests/sas/storage/blob/test_helper_extra.py | Use per-call stub class instead of mutating MagicMock.__name__. |
| src/backend-api/src/tests/sas/storage/blob/test_async_helper_extra.py | Same stub-class refactor for the async helper test. |
| src/backend-api/src/tests/sas/storage/blob/test_config.py | Remove unused pytest import and unused default_config symbol. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Roopan-Microsoft
approved these changes
May 18, 2026
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Resolves all review comments on #242 (the open
dev -> mainPR).CodeQL (
github-code-quality) — unused imports / variablessrc/processor/src/tests/unit/services/test_queue_service_internals.pytp = _task_param()intest_output_cleanup_refuses_broad_prefix._no_op_workerintest_start_service_runs_and_completes.src/processor/src/tests/unit/libs/base/test_application_base_init.pyimport inspect.applocal intest_init_loads_app_config_when_url_set.src/processor/src/tests/unit/libs/agent_framework/test_agent_speaking_capture.pydatetime/MagicMockimports.src/processor/src/tests/unit/utils/test_agent_telemetry.pyfrom datetime import UTC, datetime(only the literalUTCstring is used).src/processor/src/tests/unit/utils/test_agent_telemetry_records.pyimport pytest.src/backend-api/src/tests/sas/storage/blob/test_config.pypytestimport and unuseddefault_configsymbol (still referenced viablob_config_module.default_config).Copilot review — order-dependent MagicMock leak
src/backend-api/src/tests/sas/storage/blob/test_async_helper_extra.pysrc/backend-api/src/tests/sas/storage/blob/test_helper_extra.pyIn
_wire_credential, the tests were mutatingtype(cred).__name__on aMagicMock(). Because everyMagicMock()instance shares the sameMagicMockclass, that assignment globally renamesMagicMock— so any later test that introspectstype(...).__name__sees whatever the last test set, producing order-dependent / flaky behavior.Replaced the mutation with a dedicated dynamically-created stub class per credential type (e.g.
type('DefaultAzureCredential', (), {})). This:__name__to a fresh class per call (no leakage).hasattr(cred, 'account_key')semantics for both the account-key path (attribute set on the stub) and the AAD path (attribute absent).Verification
cd src/backend-api && PYTHONPATH=src/app pytest src/tests -c NUL --rootdir=. --cov=src/app --cov-fail-under=8293.28%coverage. (1 unrelated env failure when locally authenticated against the placeholderexample.azconfig.io; passes in CI where no Azure credentials are present.)cd src/processor && pytest src/tests --cov=src --cov-fail-under=8287.44%coverage.Does this introduce a breaking change?
Golden Path Validation
Deployment Validation